function Request(Method, CallBack){
	var conn = new Ext.data.Connection();
	conn.request({
		 url:'proxy.php',
		 params:{method: Method, returnData:true},
		 success:function(response,o){
			 //IMPLEMENTS CALLBACK
			 /*var obj = Ext.decode(response.responseText);
		     form.findById('texto').setValue(obj.values[0].text);*/
		 },
		 scope:this
	});
}

function FieldId(){
	return {
		name: 'id'
		,id:'id'
		,hideLabel: true
		,hidden:true
		,submitValue:true
	}
}
function TextField(label, id){
	return 	{
		fieldLabel: label
		,width: 300		
		,name: id
		,id:id
		,allowBlank:true
	}
}
function ComboField(label, id, store, params){

	return {
		xtype:'combo'
		,fieldLabel: label
		,width: 283	
		,store: store
		,displayField: 'nombre'
		,valueField:'id'
		,editable: true
		,forceSelection: true
		,mode:'local'
		,triggerAction: 'all'	
		,name: id
		,id:id
		,allowBlank:true
		,listeners: (params == null ) ? null : params.listeners
	}
}
function AreaField(label, id){
	return 	{
		xtype:'textarea'
		,fieldLabel: label
		,width: 300		
		,height: 200
		,name: id
		,id:id
		,allowBlank:true
	}
}
function FileField(label,id){
	return 	{	
		fieldLabel: label
		,width: 300		
		,inputType: 'file'
		,name: id
		,id: id
	}
}

function Store(obj){
	return new Ext.data.JsonStore({
        root: 'values',
        totalProperty: 'totalCount',
        idProperty: 'id',
        remoteSort: true,
		baseParams: {method: obj.method, returnData: obj.returnData},
        fields: obj.fields,
        proxy: new Ext.data.HttpProxy({
            url: 'libraries/proxy.php'
        })
    });

}

function iconButton(value, metadata, record,rowIndex,colIndex,store){
		var extension = value.split('.');
		switch(extension[extension.length-1]){
			case 'pdf': img = 'pdf_icon.png'; break;
			case 'xls': img = 'xls_icon.png'; break;
			case 'pps': img = 'pps_icon.png'; break;			
			default: img = 'file_icon.png';
		}
	
		return '<a href="../files/'+ value +'" target="_blank"><img src="img/'+img+'" height="16" width="16" border="0" alt="'+value+'"/></a>';
}

Ext.onReady(function(){
	var center = new Ext.Panel({
	    region: 'center',
	    id:'center',
	    autoScroll:true,
	    split: false,
	    collapsible: false,
	    margins:'3 0 3 3',
	    cmargins:'3 3 3 3'
	});

	var nav = new Ext.Panel({
	    title: 'Menu',
	    region: 'west',
	    split: true,
	    width: 200,
	    collapsible: true,
	    margins:'3 0 3 3',
	    cmargins:'3 3 3 3',
	    border: false,
	    bodyBorder: false,
	    hideBorders:true,
	    items:[
	           {html:'<a href="default.php" style="padding:10px;">Actividades</a>'},
	           {html:'<a href="regiones.php" style="padding:10px;">Regiones</a>'},
	           {html:'<a href="provincias.php" style="padding:10px;">Provincias</a>'},
	           {html:'<a href="ciudades.php" style="padding:10px;">Ciudades</a>'},
	           {html:'<a href="organizaciones.php" style="padding:10px;">Organizaciones</a>'},
	           {html:'<a href="categorias.php" style="padding:10px;">Categorias</a>'},
				{html:'<a href="programas.php" style="padding:10px;">Programas</a>'},
	           {html:'<a href="download.php" style="padding:10px;">Descargar ZIP</a>'},
	           {html:'<a href="downloadxls.php" style="padding:10px;">Descargar Excel</a>'},
	           {html:'<a href="sub_programas.php" style="padding:10px;">Sub Programas</a>'}
//				{html:'<a href="videos.php" style="padding:10px;">Videos</a>'}
	           ]
	});
	
	var win = new Ext.Window({
	    title: 'Administrador de Contenidos - DIRECTORIO 2010',
		id: 'mainWin',
	    closable:false,
	    maximized:true,
	    plain:true,
	    applyTo: 'content',
	    layout: 'border',
	    items: [nav, center]
	});
	
		win.show();
});
